% Main Function of type A [ a rolling-cutting manner ]
	tic;
	w=100;
	Data_File_Number =1;
% ********* The generation of coarse grid	*********
	DET=2e-4;
	X0s = -1e-3 : DET : 1e-3;
	X1s = -1e-3 : DET : 1e-3;
	X2s = -1e-3 : DET : 1e-3;
	Y0s = -1e-3 : DET : 1e-3;
	Y1s = -1e-3 : DET : 1e-3;
	Y2s = -1e-3 : DET : 1e-3;
	[X0,X1,X2,Y0,Y1,Y2]=ndgrid(X0s,X1s,X2s,Y0s,Y1s,Y2s);
	X0Hat=reshape(X0,1,size(X0s,2)*size(X1s,2)*size(X2s,2)*size(Y0s,2)*size(Y1s,2)*size(Y2s,2));
	X1Hat=reshape(X1,1,size(X0s,2)*size(X1s,2)*size(X2s,2)*size(Y0s,2)*size(Y1s,2)*size(Y2s,2));
	X2Hat=reshape(X2,1,size(X0s,2)*size(X1s,2)*size(X2s,2)*size(Y0s,2)*size(Y1s,2)*size(Y2s,2));
	Y0Hat=reshape(Y0,1,size(X0s,2)*size(X1s,2)*size(X2s,2)*size(Y0s,2)*size(Y1s,2)*size(Y2s,2));
	Y1Hat=reshape(Y1,1,size(X0s,2)*size(X1s,2)*size(X2s,2)*size(Y0s,2)*size(Y1s,2)*size(Y2s,2));
	Y2Hat=reshape(Y2,1,size(X0s,2)*size(X1s,2)*size(X2s,2)*size(Y0s,2)*size(Y1s,2)*size(Y2s,2));
% ********* The generation of coarse grid	*********	
	[ X0,X1,X2,Y0,Y1,Y2 ] = Grid_Method(w,X0Hat,X1Hat,X2Hat,Y0Hat,Y1Hat,Y2Hat,4e4,1,Data_File_Number);        % Coarse grid data
	Samples = [ X0,X1,X2,Y0,Y1,Y2 ];
	Data_File_Number = Data_File_Number+1;	
	for index = 1 : 6
% ********* The generation of refined grid	[a rolling-cutting manner:3N,3N,3N,3N,3N,3N] *********	
		if(index ==1)
		SamplesHat=[Samples(:,index)-DET/2 Samples(:,index+1:end);
				Samples(:,index) Samples(:,index+1:end);
				Samples(:,index)+DET/2 Samples(:,index+1:end);];
		elseif(index >=2)&&(index <=5)
		SamplesHat=[Samples(:,1:index-1) Samples(:,index)-DET/2  Samples(:,index+1:6);
				Samples(:,1:index-1) Samples(:,index)  Samples(:,index+1:6);
				Samples(:,1:index-1) Samples(:,index)+DET/2  Samples(:,index+1:6);];
		else
		SamplesHat=[Samples(:,1:index-1) Samples(:,index)-DET/2;
				Samples(:,1:index-1) Samples(:,index);
				Samples(:,1:index-1) Samples(:,index)+DET/2;];
		end

		X0Hat=SamplesHat(:,1)';X1Hat=SamplesHat(:,2)';X2Hat=SamplesHat(:,3)';
		Y0Hat=SamplesHat(:,4)';Y1Hat=SamplesHat(:,5)';Y2Hat=SamplesHat(:,6)';
% ********* The generation of refined grid	[a rolling-cutting manner:3N,3N,3N,3N,3N,3N] *********		
		[ X0,X1,X2,Y0,Y1,Y2 ] = Grid_Method(w,X0Hat,X1Hat,X2Hat,Y0Hat,Y1Hat,Y2Hat,1000,0.1,Data_File_Number);        % Coarse grid data	
		Samples=uniquetol([ X0,X1,X2,Y0,Y1,Y2 ],1e-8,'ByRows',true);		
		Data_File_Number = Data_File_Number+1;
	end
	DET=DET/2;
	toc; 